<!DOCTYPE html>
<html>
<head>
    {include file="public/header" /}
    <style>
        .pointer {
            cursor: pointer
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form layui-form-pane">
    <div class="layui-form-item">
        <label class="layui-form-label pointer required" onclick="checkMemberInfo('{$info.sell_code}')">投诉人名称</label>
        <div class="layui-input-inline" onclick="checkMemberInfo('{$info.sell_code}')">
            <input type="text" value="{$info.sell_name}" readonly autocomplete="off" class="layui-input pointer">
        </div>
        <label class="layui-form-label pointer required" onclick="checkMemberInfo('{$info.sell_code}')">投诉人手机号</label>
        <div class="layui-input-inline" onclick="checkMemberInfo('{$info.sell_code}')">
            <input type="number" value="{$info.sell_phone}" readonly autocomplete="off" class="layui-input pointer">
        </div>
    </div>
    <div class="layui-form-item">
        <input type="hidden" name="id" value="{$info.id}">
        <label class="layui-form-label pointer required" onclick="checkMemberInfo('{$info.buy_code}')">被投诉人名称</label>
        <div class="layui-input-inline" onclick="checkMemberInfo('{$info.buy_code}')">
            <input type="text" value="{$info.buy_name}" readonly autocomplete="off" class="layui-input pointer">
        </div>
        <label class="layui-form-label pointer required" onclick="checkMemberInfo('{$info.buy_code}')">被投诉人手机</label>
        <div class="layui-input-inline" onclick="checkMemberInfo('{$info.buy_code}')">
            <input type="number" value="{$info.buy_phone}" readonly autocomplete="off" class="layui-input pointer">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">投诉原因</label>
        <div class="layui-input-inline">
            <input type="text" value="{$info.reason|getComplaintReason}" readonly autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label required">举报内容</label>
        <div class="layui-input-inline" style="width: 70%">
            <input type="text" value="{$info.complaint_context}" readonly autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">查看截图</label>
        <div class="" style="display: flex">
            {volist name='info.screenshot' id='v'}
            <div class="layui-upload-list" style="margin-top: 5px;cursor: pointer" onclick="showImg('{$v}')">
                <img class="layui-upload-img headImage" style="height: 100px;" src="/upload/{$v}">
            </div>
            {/volist}
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">状态</label>
        <div class="layui-input-inline">
            <input type="text" value="{$info.handle_status|getComplaintHandelStatus}" readonly autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label required">投诉时间</label>
        <div class="layui-input-inline">
            <input type="text" value="{$info.create_time}" readonly autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">分类</label>
        <div class="layui-input-inline">
            <input type="text" value="{$info.type_mark|getComplaintType}" readonly autocomplete="off" class="layui-input">
        </div>
        {if condition="$info.type_mark==2"}
        <label class="layui-form-label required">出售类型</label>
        <div class="layui-input-inline">
            {if condition="$tradingInfo.type==1"}
            <input type="text" value="金币" readonly autocomplete="off" class="layui-input">
            {else/}
            <input type="text" value="积分" readonly autocomplete="off" class="layui-input">
            {/if}
        </div>
        <label class="layui-form-label required">数量</label>
        <div class="layui-input-inline">
            <input type="text" value="{$tradingInfo.num}" readonly autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label required">金额</label>
        <div class="layui-input-inline">
            <input type="text" value="{$tradingInfo.price|priceFormat}" readonly autocomplete="off" class="layui-input">
        </div>
        {/if}
    </div>
    {if condition="$info.status==1"}
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn " lay-submit lay-filter="adopt">审核通过</button>
            <button class="layui-btn  layui-btn-danger" lay-submit lay-filter="reject">审核驳回</button>
        </div>
    </div>
    {/if}
</div>
{include file="public/footer" /}
<script>
    layui.use(['form', 'laydate', 'tableSelect', 'layarea', 'upload'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;
        var index;
        //审核通过
        form.on('submit(adopt)', function (data) {
            index = layer.confirm('确定判定购买方违规吗？<br/>判定违规后，将终止双方交易，并恢复相关状态，购买方将被冻结账号！', function (index) {
                submitInfo('adopt');
            });
            return false;
        });
        //审核驳回
        form.on('submit(reject)', function (data) {
            submitInfo('reject');
            return false;
        });

        /*提交*/
        function submitInfo(type) {
            $.ajax({
                url: '/admin/PlatformData/complaint?action=violations',
                type: 'post',
                dataType: 'json',
                data: {id: "{$info.id}", type: type},
                success: function (res) {
                    if (res.status == true) {
                        // 关闭弹出层
                        layer.msg("操作成功");
                        layer.close(index);
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(iframeIndex);
                        window.parent.location.reload();
                    } else {
                        layer.close(index);
                        layer.msg(res.msg);
                    }
                },
                error: function () {
                    layer.msg("报错了");
                }
            });
        }
    });

    function checkMemberInfo(code) {
        var index = layer.open({
            title: '用户详情',
            type: 2,
            shade: 0.2,
            maxmin: true,
            shadeClose: true,
            area: ['100%', '100%'],
            content: '/admin/Member/write?code=' + code,
        });
    }
    /*查看大图*/
    function showImg(img) {
        if (img != '' && img != null && img != 'null') {
            var img = img.split(',');
            var imgHtml = '';
            var width = 50;
            for (i = 0; i < img.length; i++) {
                width = width + 450;
                imgHtml += "<img src='/upload/" + img[i] + "' width='400px'  style='margin-left:50px;margin-top:25px'>";
            }
            var explainopen = layer.open({
                type: 1,
                title: '图片',
                area: [width + 'px', '500px'],
                shadeClose: true,
                content: imgHtml
            });
        } else {
            layer.msg('图片为空');
        }
    }
</script>
</body>
</html>